package com.lagou;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConsumerMain {
    public static void main(String[] args) throws IOException {
        // 启动容器
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        annotationConfigApplicationContext.start();
        ApiService apiService = annotationConfigApplicationContext.getBean(ApiService.class);
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        while (true) {
             System.in.read();
            //bean.work();
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    apiService.methodA();
                    apiService.methodB();
                    apiService.methodC();
                }
            });
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan("com.lagou")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
